<?php include $this->admin_tpl('meta');?>
<title>成分找款</title>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/jquery/1.8.2/jquery.min.js"></script> 
</head>
<body>
<div class="page-container" style="padding-bottom:0;">
	<form id="search">
		<input type="hidden" value="" name="field">
		<input type="hidden" value="" name="order">
		<input type="hidden" value="0" name="download">
		<div class="c"><input type="text" name="name" class="input-text" autocomplete="off" style="width:130px" placeholder="商品名称" value="<?php if(isset($_GET['name'])) echo $_GET['name'];?>"></div>
		<div class="c"><input type="text" name="color" class="input-text" autocomplete="off" style="width:130px" placeholder="颜色" value="<?php if(isset($_GET['properties_value'])) echo $_GET['properties_value'];?>"></div>
		<div class="c"><input type="text" name="other_2" class="input-text" autocomplete="off" style="width:130px" placeholder="其他属性2" value="<?php if(isset($_GET['other_2'])) echo $_GET['other_2'];?>"></div>
		
		<div class="list_box c" style="float:left;">
			<input type="text" name="ups" class="input-text" style="width:230px" autocomplete="off" placeholder="面料成份" value="<?php if(isset($_GET['ups'])) echo $_GET['ups'];?>">
			<div class="select" style="width:230px;">
				<ul id="ups">
				</ul>
			</div>
		</div>
		<div class="list_box c" style="float:left;">
			<input type="text" name="remark" class="input-text" style="width:230px" autocomplete="off" placeholder="商品备注成份" value="<?php if(isset($_GET['ups'])) echo $_GET['ups'];?>">
			<div class="select" style="width:230px;">
				<ul id="remark">
				</ul>
			</div>
		</div>
		<?php include $this->admin_tpl('jst_common/select_category');?>
		<?php include $this->admin_tpl('jst_common/select_brand');?>
		<div class="c"><a class="btn btn-success radius" href="javascript:void(0)" id="btn_search"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</a></div>
		<div class="c"><button class="btn btn-primary radius" id="btn_reset" type="reset"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</button></div>
		<div class="c" style="line-height:30px;"><input name="is_ys" type="checkbox" checked value="1">只筛选佑晟品牌</div>
	</form>
	
	<table id="table" class="mt-20" lay-filter="table" style="font-size:12px;"></table>
</div>
<?php include $this->admin_tpl('jst_common/common_tpl');?>
<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/layui/layui.js"></script>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/laydate/1.1/laydate.js"></script>
<script>
var db = 'jst_inventorys';
layui.use(function(){ //亦可加载特定模块：layui.use(['layer', 'laydate', function(){
	table = layui.table; //表格
	util = layui.util; //工具集
	dropdown = layui.dropdown; //下拉菜单
	form = layui.form;
	//执行一个 table 实例
	option = {
		elem: '#table',
		id:'table',
		height: 'full-80',
		limit:30,
		limits:[20,60,90],
		url:'<?php echo U('ys_zhaokuan');?>',
		method:'post',
		where: $('#search').serializeJson(),
		title: '商品列表',
		autoSort: false,
		page: {theme:'#409eff',groups:3,hash:true}, //开启分页
		//toolbar: '#tool_temp', //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
		cols: [[ //表头
			{type: 'checkbox'},
			{field: 'pic', title: '图片', width:40,align:'center',templet: '#pic_tpl'},
			{field: 'i_id', title: '款式编码', width:150,align:'left',templet:'#vip_link'},
			{field: 'name', title: '商品名称',width:150},
			{field: 'brand', title: '品牌',align:'center',width:100},
			{field: 'other_2', title: '其他属性2',align:'left',width:180},
			{field: 'color', title: '颜色',align:'left',width:150},
			{field: 'category', title: '商品分类',width:150},
			{field: 'pv_value', title: '面料成分',width:300},
			{field: 'remark', title: '商品备注',width:300},
			{field: 'jst_name', title: '商品来源',align:'center',width:80,totalRow: '小计：'},
			{field: 'modified', title: '修改时间',align:'center',sort:true,width:110}
		]],
		done:function(res,curr,count){
			$('.qty_sum').remove();
			//$('.layui-table-page').append('<div class="layui-inline f-l qty_sum" style="line-height:26px;">主仓库存共 <span class="c-primary f-16">'+res.qty_sum+'</span> 件</div>');
			var options = this;
			public_table(db);
		}
	};
	table.render(option);
	init_table(db);
})
$('input[name="ups"]').bind('input focus', function() {
	ups('ups');
});
$('input[name="remark"]').bind('input focus', function() {
	ups('remark');
});
$('#ups>li').live('click',function(){
	$('input[name="ups"]').val($(this).text());
	$('#ups').parent().hide();
	$('#ups').html('');
});
$('#ups>li').live('click',function(){
	$('input[name="ups"]').val($(this).text());
	$('#ups').parent().hide();
	$('#ups').html('');
})
$('#remark>li').live('click',function(){
	$('input[name="remark"]').val($(this).text());
	$('#remark').parent().hide();
	$('#remark').html('');
});
$('#remark>li').live('click',function(){
	$('input[name="remark"]').val($(this).text());
	$('#remark').parent().hide();
	$('#remark').html('');
})
function ups(type){
	var ups = jQuery.trim($('input[name="'+type+'"]').val());
	var brand = $('input[name="brand"]').val();
	if(ups.length>3){
		$('#'+type).html('');
		$.ajax({
			type: 'get',
			url: '<?php echo U('ys_zhaokuan');?>?type=get_'+type+'&brand='+brand, 
			data: {ups:ups},
			dataType: "json", 
			success: function (res) {
				if(res['status']==1){
					$.each(res['data'],function(i,val){
						$('#'+type).append('<li>'+val['pv_value']+'</li>');
						$('#'+type).parent().show();
					});
				}
			}
		})
	}
}
function color(){
	var color = jQuery.trim($('input[name="properties_value"]').val());
	if(color.length>0){
		$('#color').html('');
		$.ajax({
			type: 'get',
			url: '<?php echo U('ys_zhaokuan');?>?type=get_color', 
			data: {color:color},
			dataType: "json", 
			success: function (res) {
				if(res['status']==1){
					$.each(res['data'],function(i,val){
						$('#color').append('<li>'+val['color']+'</li>');
						$('#color').parent().show();
					});
				}
			}
		})
	}
}
</script>
</body>
</html>